package batchjob;

import java.util.Hashtable;

/** If you want to use the batchjob scheduler you must provide a class that
    implements this interface, which is usually the EA-framework. 
    The interface is used to build the connection
    between the scheduler and the algorithm itself. It defines the necessary
    methods needed for the starting of the algorithm, extraction of data, etc.
    <br>
    When the scheduler controls the algorithm it goes though the following
    steps.
    <ol>
    <li>Generate the hashtable according to the settings loaded/generated.
    <li>Call setSettings from your provided class.
    <li>Call intializeAndStartEA in order to run the algorithm.
    <li>If specified in the input file it will call the appropriate extraction
    methods and generate the various datatypes.
    </ol>
    @see EA.BatchJobScheduler
*/
public interface BatchJob {

  /** Set the settings for the algorithm. The passed hashtable contains
	only String objects which are all related to the input file given 
	to the scheduler. 
    */
  public void setSettings(Hashtable settings);

  /** Get the default settings in the BatchJobScheduler format. This 
	method can be used to reconstruct an input file for the scheduler. 
    */
  public String getDefaultSettings();

  /** Initialize a batchjob. This is called once before any run is performed.
    */
  public void initializeBatchJobs();

  /** Finalize a batchjob. This is called once after all runs are performed.
    */
  public void finalizeBatchJobs();

  /** Initialize a run series. This is called once before the specified 
	number of runs are performed. (BJSruns in the batchfile)
    */
  public void initializeRunSeries();

  /** Finalize a run series. This is called once after the specified 
	number of runs are performed. (BJSruns in the batchfile)
    */
  public void finalizeRunSeries();

  /** Initialize and start a single run of the algorithm. You can 
	usually just call doEA() from your framework.
     */
  public void initializeAndStartRun();

  /** Finalize the single run of the algorithm. This is called immediately
	after the initializeAndStartRun(). It can be used to reset 
	measurements, increase counters, etc.
     */
  public void finalizeRun();

  /** Get the run data as text. Your implementation must return
	an array of objects that each implements the interface ConvertToText from the package
	EA.recording. You can use the classes found in EA.recording or 
	implement your own classes.
	@see EA.recording.ConvertToText
    */
  public Object[] getDataAsText();

}
